/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package centralehotel.modele;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Mathieu
 */
@Entity
@Table(name = "chambre")
@NamedQueries({@NamedQuery(name = "Chambre.findByIdChambre", query = "SELECT c FROM Chambre c WHERE c.idChambre = :idChambre"), @NamedQuery(name = "Chambre.findByNom", query = "SELECT c FROM Chambre c WHERE c.nom = :nom")})
public class Chambre implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id_chambre", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer idChambre;
    @Column(name = "nom")
    private String nom;
    @JoinColumn(name = "type_chambre", referencedColumnName = "id_type_chambre")
    @ManyToOne
    private TypeChambre typeChambre;
    @JoinColumn(name = "fiche_hotel", referencedColumnName = "id_fiche_hotel")
    @ManyToOne
    private FicheHotel ficheHotel;
    @OneToMany(mappedBy = "chambre", cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    private Collection<Reservation> reservationCollection;

    public Chambre() {
    }

    public Chambre(Integer idChambre) {
        this.idChambre = idChambre;
    }

    public Integer getIdChambre() {
        return idChambre;
    }

    public void setIdChambre(Integer idChambre) {
        this.idChambre = idChambre;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public TypeChambre getTypeChambre() {
        return typeChambre;
    }

    public void setTypeChambre(TypeChambre typeChambre) {
        this.typeChambre = typeChambre;
    }

    public FicheHotel getFicheHotel() {
        return ficheHotel;
    }

    public void setFicheHotel(FicheHotel ficheHotel) {
        this.ficheHotel = ficheHotel;
    }

    public Collection<Reservation> getReservationCollection() {
        return reservationCollection;
    }

    public void setReservationCollection(Collection<Reservation> reservationCollection) {
        this.reservationCollection = reservationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idChambre != null ? idChambre.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Chambre)) {
            return false;
        }
        Chambre other = (Chambre) object;
        if ((this.idChambre == null && other.idChambre != null) || (this.idChambre != null && !this.idChambre.equals(other.idChambre))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "centralehotel.exception.Chambre[idChambre=" + idChambre + "]";
    }

}
